﻿using System;
using System.Collections.Generic;

namespace Boxi.Extensions
{
    public static partial class ListExtensions
    {
        /// <summary>
        /// 
        /// </summary>
        public static T GetRandom<T>(this IList<T> list)
        {
            if (list.Count == 0)
                throw new Exception("List item can not be Zero");

            return list[(new Random()).Next(list.Count - 1)];
        }  
        /// <summary>
        /// 
        /// </summary>
        public static T GetRandom<T>(this T[] list)
        {
            if (list.Length == 0)
                throw new Exception("List item can not be Zero");

            return list[(new Random()).Next(list.Length - 1)];
        }
        public static void HelloWorld(this Object obj)
        {
            throw new Exception("Hello World");
        }
    }
}
